from helpers.director.shortcut import ModelTable,TablePage,ModelFields,director,page_dc
from . models import FailKind

class FailKindPage(TablePage):
    def get_label(self):
        return '不合格种类'
    def get_template(self, prefer=None):
        return 'jb_admin/table_new.html'
    
    class tableCls(ModelTable):
        model = FailKind
        exclude =[]
        button_edit = True
        #pop_edit_fields = ['id']

        def dict_head(self, head):
            width = {
                'name':200
            }
            head['width'] = width.get(head['name'])
            return head
        
  

class FailKindForm(ModelFields):
    class Meta:
        model = FailKind
        exclude =[]
    def get_head_context(self):
        ctx = super().get_head_context()
        ctx.update({
            'width':'650px',
            'height':'200px',
            'title':'创建不合格种类'
        })
        return ctx        

director.update({
    'failkind':FailKindPage.tableCls,
    'failkind.edit':FailKindForm,
    
})

page_dc.update({
    'failkind':FailKindPage
})